package com.xxd.spring.boot.demo.zhuhongbing.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.zhuhongbing.util.Result;
import com.xxd.spring.boot.demo.zhuhongbing.entity.Classes;
import com.xxd.spring.boot.demo.zhuhongbing.service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/classes")
public class ClassesController {
    @Autowired
    private ClassesService classesService;
    @RequestMapping("/add")
    public Result add(@RequestBody Classes classes){
        classesService.add(classes);
        return new Result().success();
    }
    @RequestMapping("/update")
    public Result update(@RequestBody Classes classes){
        classesService.update(classes);
        return new Result().success();
    }
    @RequestMapping("/delete/{id}")
    public Result delete(@PathVariable("id") int id){
        classesService.delete(id);
        return new Result().success();
    }
    @RequestMapping("/listPage")
    public Result listPage(Page page, @RequestParam Map<String,Object> params){
        IPage<Classes> resPage=classesService.listpage(page,params);
        return new Result().success().setData(resPage);
    }
    @RequestMapping("/list")
    public Result list(@RequestBody Map<String,Object> params){
        List<Classes> list=classesService.list(params);
        return new Result().success().setData(list);
    }
    @RequestMapping("/infoById/{id}")
    public Result infoById(@PathVariable("id") int id){
        Classes classes=classesService.infoById(id);
        return new Result().success().setData(classes);
    }
}
